package com.mystudy.netty.http.standard;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @program: infoalgorithm
 * @description: 服务端初始化类
 * @author: zhouzhilong
 * @create: 2019-10-25 17:13
 **/
public class HttpPipelineInitializer extends ChannelInitializer<Channel> {
    @Override
    protected void initChannel(Channel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        //http的编解码器
        pipeline.addLast("codec",new HttpServerCodec());
        //一个请求最大只允许512kb
        pipeline.addLast("aggregator",new HttpObjectAggregator(512*1024));
        //业务处理器
        pipeline.addLast(new HttpServerHandler());
    }
}
